package cn.iocoder.yudao.module.leverage.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.EnumUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
@AllArgsConstructor
public enum ExpandStatusEnum implements ArrayValuable<Integer> {
    UNCHECK(1, "未审核"),
    REJECT(2, "审核未通过"),
    APPROVED(3, "扩资通过");

    private final Integer type;

    private final String title;

    public static ExpandStatusEnum getByType(Integer type) {
        return EnumUtil.getBy(ExpandStatusEnum.class,
                e -> Objects.equals(type, e.getType()));
    }

    public static ExpandStatusEnum typeOf(Integer type) {
        return ArrayUtil.firstMatch(item -> item.getType().equals(type), values());
    }

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(ExpandStatusEnum::getType).toArray(Integer[]::new);

    @Override
    public Integer[] array() {
        return ARRAYS;
    }
}
